
/**对象中删除值为空的key */
export function filterObj(target: Record<string, any>) {
  const obj = {}
  for (let key in target) {
    if (target[key]) {
      obj[key] = target[key]
    }
  }
  return obj
}

// 判断手机号是否正确
export function validatePhone(val) {
  let reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
  return reg.test(val)
}

/**请求对象转请求字符串 */
export function formatQueryParams(target: Record<string, any>) {
  let str = ''
  for (let key in target) {
    if (target[key]) {
      str += `&${key}=${target[key]}`
    }
  }
  return '?' + str.slice(1)
}